package com.trhui.mallbook.domain.common;

import com.trhui.mallbook.constant.MallBookConstant;

/**
 * 基础响应
 * 
 * @author huangh
 * @version 1.0
 * @description
 * @date 2023/08/15 0015 16:38
 */

public class BaseResponse<T> {

    /**
     * 结果代码（0000为响应成功）
     * 详细返回码请查看接口文档
     */
    private String code;

    /**
     * 结果信息
     */
    private String msg;

    /**
     * 当 code == 0000，返回 data
     * 通过 data 里面的 status 做业务处理
     */
    private T data;

    public BaseResponse(ApiResponse apiResponse) {
        this.code = apiResponse.getCode();
        this.msg = apiResponse.getMsg();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean success() {
        return MallBookConstant.SUCCESS_CODE.equals(code);
    }
}
